<template>
	<view>
		<!-- <uni-swipe-action :options="options" :item="item" @click="bindClick"> -->
		<view class="box">
			<view class="box-item">
				<view class="box-item-left">
					{{item.start_time}}
				</view>
				至
				<view class="box-item-right">
					{{item.end_time}}
				</view>
			</view>
			<view class="box-item">
				<view class="box-item-left" style="width:75%;">
					<text>事由：{{item.reason}}</text>
				</view>
				<view class="box-item-right" style="width:21%;">
					<uni-tag :text="item.status==1?'不同意':item.status==2?'审核中':'已通过'" 
					:type="item.status==1?'error':item.status==2?'primary':'success'" 
					size="small"></uni-tag>
				</view>
			</view>
			</view>
		<!-- </uni-swipe-action> -->
	</view>
</template>

<script>
	// import uniSwipeAction from "@/components/uni-swipe-action/uni-swipe-action.vue"
	import uniTag from '@/components/uni-tag/uni-tag.vue'
	import {apideleLeave} from '@/common/api.js'
	export default{
		name:'mycard',
		data(){
			return{
				options: [{
                text: '取消',
                style: {
                    backgroundColor: '#007aff'
                }
            }, {
                text: '删除',
                style: {
                    backgroundColor: '#dd524d'
                }
            }]
			}
		},
		components:{
			uniTag,			
			// uniSwipeAction
		},
		props:{
			item: Object
		},
		methods:{
			bindClick(e){
				console.log(JSON.stringify(e))
				if(e.index==1&&e.item.status==3){
					apideleLeave({
						leaveId:e.item.id
						}).then(res=>{
						console.log(JSON.stringify(res))
					}).catch(err=>{
						console.log(JSON.stringify(err))
					})
				}else if(e.index==1&&e.item.status!=3){
					this.toast('已审核无法删除')
				}
			},
			toast(title,icon='none'){
				uni.showToast({
					title: title,
					mask: true,
					icon:icon,
					duration: 1500
				});
			}			
		}
	}
</script>

<style lang="scss" scoped>
	.box{
		width: 100%;
		border-radius: $uni-border-radius-base;
		border-bottom:1upx solid $uni-border-color;
		background: $uni-bg-color;
		.box-item{
			width:96%;
			padding:0 2%;
			height:$card-height;
			line-height: $card-height;
			.box-item-left{
				width: 48%;
				float: left;
				text-align: left;
				line-height: $card-height;
				overflow: hidden;
				text-overflow:ellipsis;
				white-space: nowrap;
			}
			.box-item-right{
				line-height: $card-height;
				width: 48%;
				float: right;
				text-align: right;
			}
		}
	}
</style>
